package com.restaurant.application.level.support;

import com.google.common.collect.Lists;
import com.nebutown.generation.Convert;
import com.nebutown.generation.PickableBean;

import java.util.List;

public class LevelData implements PickableBean {

    public static final String FN_ID = "id";
    public static final String FN_MEMBERLEVEL = "memberLevel";
    public static final String FN_MEMBERNAME = "memberName";
    public static final String FN_SCORE = "score";
    public static final String FN_CREATETIME = "createTime";
    public static final String FN_MODIFYTIME = "modifyTime";

    public static final List<String> FIELD_NAMES = Lists.newArrayList(
            FN_ID,
            FN_MEMBERLEVEL,
            FN_MEMBERNAME,
            FN_SCORE,
            FN_CREATETIME,
            FN_MODIFYTIME);
    
    private String id;
    private Integer memberLevel;
    private String memberName;
    private Integer score;
    private Long createTime;
    private Long modifyTime;

    public LevelData(String id, Integer memberLevel, String memberName, Integer score, Long createTime, Long modifyTime) {
        setId(id);
        setMemberLevel(memberLevel);
        setMemberName(memberName);
        setScore(score);
        setCreateTime(createTime);
        setModifyTime(modifyTime);
    }

    public LevelData() {
    }

    public LevelData duplicate() {
        LevelData result = new LevelData();
        result.id = this.id;
        result.memberLevel = this.memberLevel;
        result.memberName = this.memberName;
        result.score = this.score;
        result.createTime = this.createTime;
        result.modifyTime = this.modifyTime;
        return result;
    }

    @Override
    public String toString() {
        return Convert.toJson(this);
    }

    public String getId() {
        return id;
    }

    public void setId(String value) {
        this.id = value;
    }

    public LevelData withId(String value) {
        setId(value);
        return this;
    }

    public LevelData withId(String value, String defaultValue) {
        setId(value == null ? defaultValue : value);
        return this;
    }

    public Integer getMemberLevel() {
        return memberLevel;
    }

    public void setMemberLevel(Integer value) {
        this.memberLevel = value;
    }

    public LevelData withMemberLevel(Integer value) {
        setMemberLevel(value);
        return this;
    }

    public LevelData withMemberLevel(Integer value, Integer defaultValue) {
        setMemberLevel(value == null ? defaultValue : value);
        return this;
    }

    public String getMemberName() {
        return memberName;
    }

    public void setMemberName(String value) {
        this.memberName = value;
    }

    public LevelData withMemberName(String value) {
        setMemberName(value);
        return this;
    }

    public LevelData withMemberName(String value, String defaultValue) {
        setMemberName(value == null ? defaultValue : value);
        return this;
    }

    public Integer getScore() {
        return score;
    }

    public void setScore(Integer value) {
        this.score = value;
    }

    public LevelData withScore(Integer value) {
        setScore(value);
        return this;
    }

    public LevelData withScore(Integer value, Integer defaultValue) {
        setScore(value == null ? defaultValue : value);
        return this;
    }

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long value) {
        this.createTime = value;
    }

    public LevelData withCreateTime(Long value) {
        setCreateTime(value);
        return this;
    }

    public LevelData withCreateTime(Long value, Long defaultValue) {
        setCreateTime(value == null ? defaultValue : value);
        return this;
    }

    public Long getModifyTime() {
        return modifyTime;
    }

    public void setModifyTime(Long value) {
        this.modifyTime = value;
    }

    public LevelData withModifyTime(Long value) {
        setModifyTime(value);
        return this;
    }

    public LevelData withModifyTime(Long value, Long defaultValue) {
        setModifyTime(value == null ? defaultValue : value);
        return this;
    }

    public Object getValueOf(String name) {
        switch (name) {
            case "id":
                return getId();
            case "memberLevel":
                return getMemberLevel();
            case "memberName":
                return getMemberName();
            case "score":
                return getScore();
            case "createTime":
                return getCreateTime();
            case "modifyTime":
                return getModifyTime();
        }
        return null;
    }

    public boolean hasField(String name) {
        return FIELD_NAMES.contains(name);
    }

    @Override
    public int hashCode() {
        return signature().hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof LevelData)) return false;
        return signature().equals(((LevelData) o).signature());
    }

    public String signature() {
        throw new RuntimeException("Bean LevelData has no signature defined, no hash code or equals possible.");
    }
}
